<?php
//include_once './config.inc.php';

/**
 * 在这里输入本目录下的特定变量
 */
$GLOBALS['runtime']['end'] = microtime(true);
$GLOBALS['runtime']['start_end'] = $GLOBALS['runtime']['end'] - $GLOBALS['runtime']['start'];
 
//if(isset($T)){
	
	/*******************************************************************************
	 * 所有商品分类：左边分类导航、弹出分类导航、分类导航页
	 *******************************************************************************/
	if(isset($__f_goods_cats)/* && ($__frm == '' || $__frm == 'user')*/){
		$vars['_cats'] = $__f_goods_cats['category_tree'];
	}
	
	/*******************************************************************************
	 * 栏目高亮 & 当前位置
	 *******************************************************************************/
	if($__f_sysvars['url_rewrite'] == 'html' || $__f_sysvars['url_rewrite'] == 'rewrite'){
		$__menus = array(
			'index'		=> array('title'	=> '首页',		'url' => WEB_DIR,					'target' => '_self', 'description' => ''),
		);
		foreach($__f_goods_cats['category_list'] as $category){
			if($category['show'] == '1'){
				$__menus["{$category['mark']}"] = array('title'	=> $category['name'],	'url' => PUB_DIR."goods/{$category['mark']}/",	'target' => '_self', 'description' => '');
			}
		}
		$__menus['news']	= array('title'	=> '新闻动态',	'url' => PUB_DIR.'news/',			'target' => '_self', 'description' => '');
		$__menus['bbs']		= array('title'	=> '社区',		'url' => 'http://www.xer345.com/club/',	'target' => '_self', 'description' => '');
		$vars['goods_serach_url'] = PUB_DIR.'goods/search.do';
		switch($__mdl){
			case 'goods':
				url_here('商品展示', PUB_DIR.'goods/');
				break;
			case 'news':
				url_here('新闻动态', PUB_DIR.'news/');
				break;
			case 'brand':
				url_here('品牌故事', PUB_DIR.'brand/');
				break;
			case 'ads':
				url_here('广告中心', PUB_DIR.'ads/');
				break;
			case 'cart':
				url_here('购物车', "/index.php?mdl={$__mdl}&do={$__do}");
				break;
			case 'flow':
				url_here('下单流程', "/index.php?mdl=cart&do=list");
				break;
			case 'pay':
				url_here('支付流程', "/index.php?mdl=cart&do=list");
				break;
			case 'user':
				url_here('用户中心', '/index.php?frm=user');
				break;
			case 'sitemap':
				url_here('网站地图', PUB_DIR.'sitemap.html');
				break;
		}
	}else{
		$__menus = array(
			'index'		=> array('title'	=> '首页',		'url' => WEB_DIR,										'target' => '_self', 'description' => ''),
		);
		foreach($__f_goods_cats['category_list'] as $category){
			if($category['show'] == '1'){
				$__menus["{$category['mark']}"] = array('title'	=> $category['name'],	'url' => WEB_DIR."index.php?mdl=goods&mark={$category['mark']}",	'target' => '_self', 'description' => '');
			}
		}
		$__menus['news']	= array('title'	=> '新闻动态',	'url' => WEB_DIR.'index.php?mdl=news',			'target' => '_self', 'description' => '');
		$__menus['bbs']		= array('title'	=> '社区',		'url' => 'http://www.xer345.com/club/',	'target' => '_self', 'description' => '');
		$vars['goods_serach_url'] = WEB_DIR.'index.php?mdl=goods';
		switch($__mdl){
			case 'goods':
				url_here('商品展示', WEB_DIR.'index.php?mdl=goods');
				break;
			case 'news':
				url_here('新闻动态', WEB_DIR.'index.php?mdl=news');
				break;
			case 'brand':
				url_here('品牌故事', WEB_DIR.'index.php?mdl=brand');
				break;
			case 'ads':
				url_here('广告中心', WEB_DIR.'index.php?mdl=ads');
				break;
			case 'cart':
				url_here('购物车', "/index.php?mdl={$__mdl}&do={$__do}");
				break;
			case 'flow':
				url_here('下单流程', "/index.php?mdl=cart&do=list");
				break;
			case 'pay':
				url_here('支付流程', "/index.php?mdl=cart&do=list");
				break;
			case 'user':
				url_here('用户中心', '/index.php?frm=user');
				break;
			case 'sitemap':
				url_here('网站地图', WEB_DIR.'index.php?mdl=sitemap');
				break;
		}
	}
	if(!empty($_GET['mark']) && array_key_exists($_GET['mark'], $__menus)){
		$__menu_highlight = $_GET['mark'];
	}elseif(array_key_exists($__mdl, $__menus)){
		$__menu_highlight = $__mdl;
	}
	$vars['_menus'] = $__menus;
	$vars['_menu_highlight'] = $__menu_highlight;
	if($__menu_highlight != '' && array_key_exists($__menu_highlight, $__menus) && $__menus[$__menu_highlight]['description'] != ''){
		$__pageinfo['description'] = $__menus[$__menu_highlight]['description'];
	}
	
	
	if($__frm == 'user'){
		url_here('用户中心', WEB_DIR.'index.php?frm=user');
	}
	url_here('首页', WEB_DIR);
	krsort($__url_here);
	$vars['_url_here'] = implode('&nbsp;&gt;&nbsp;', $__url_here);
	
	if(empty($__pageinfo['title'])){
		$__pageinfo['title'] = strip_tags($__url_here[0]);
	}
	if(count($__url_here) > 2){
		$__pageinfo['title'] .= '-'.strip_tags($__url_here[1]);
	}
	$__pageinfo['title'] .= '-'.$__f_sysvars['shop_name'];
	if(empty($__pageinfo['description'])){// 页面描述
		$__pageinfo['description'] = $__l['site_description'];
	}
	if(empty($__pageinfo['keywords'])){	// 页面关键字
		$__pageinfo['keywords'] = $__l['site_keywords'];
	}
	
	$vars['_pageinfo'] = $__pageinfo;	// 页面信息
	$vars['_userinfo'] = array();	// 当前用户信息
	foreach($__userinfo as $key => $val){
		if(is_string($val)){
			if($key == 'synjs'){
				$vars['_synjs'] = $val;
			}else{
				$vars['_userinfo'][$key] = str_replace("\n", '', $val);
			}
		}elseif(is_numeric($val)){
			$vars['_userinfo'][$key] = $val;
		}
	}
	if(isset($vars['_userinfo']['password']))unset($vars['_userinfo']['password']);
	
	$vars['l'] = $__l;					// 语言包
	
	if(isset($__uri)){
		$vars['_fileurl'] = WEB_URL.str_replace('.html', '.mk', $__uri).'?remake=yes&t='.TIME;
		$vars['_fmktime'] = TIME;
	}
	/*******************************************************************************
	 * 导航链接
	 *******************************************************************************/
	if($__f_sysvars['url_rewrite'] == 'html' || $__f_sysvars['url_rewrite'] == 'rewrite'){
		$vars['_linknav'] = array(
			'cats'			=> PUB_DIR.'goods/cats.html',
			'help'			=> PUB_DIR.'news/help/',
			'sitemap'		=> PUB_DIR.'sitemap.html',
			#
			'pay'			=> PUB_DIR.'news/payment/',
			'car'			=> PUB_DIR.'news/delivery/',
			'heart'			=> PUB_DIR.'news/service/',
			#
			'430'			=> PUB_DIR.'news/2013/05/430.html',
			'431'			=> PUB_DIR.'news/2013/05/431.html',
			'432'			=> PUB_DIR.'news/2013/05/432.html',
			'433'			=> PUB_DIR.'news/2013/05/433.html',
			'434'			=> PUB_DIR.'news/2013/05/434.html',
			'435'			=> PUB_DIR.'news/2013/05/435.html',
			'436'			=> PUB_DIR.'news/2013/05/436.html',
			'437'			=> PUB_DIR.'news/2013/05/437.html',
			'438'			=> PUB_DIR.'news/2013/05/438.html',
			'439'			=> PUB_DIR.'news/2013/05/439.html',
			'440'			=> PUB_DIR.'news/2013/05/440.html',
			'441'			=> PUB_DIR.'news/2013/05/441.html',
			'442'			=> PUB_DIR.'news/2013/05/442.html',
			'443'			=> PUB_DIR.'news/2013/05/443.html',
			#
			'about-us'		=> PUB_DIR.'news/v/about-us.html',
			'contact-us'	=> PUB_DIR.'news/v/contact-us.html',
			'jobs'			=> PUB_DIR.'news/v/jobs.html',
			'joinin'		=> PUB_DIR.'news/v/joinin.html',
			'law'			=> PUB_DIR.'news/v/law.html',
			'ads'			=> PUB_DIR.'news/v/ads.html',
			'links'			=> PUB_DIR.'news/v/links.html',
		);
	}else{
		$vars['_linknav'] = array(
			'cats'			=> WEB_DIR.'index.php?mdl=goods&do=cats',
			'help'			=> WEB_DIR.'index.php?mdl=news&mark=help',
			'sitemap'		=> WEB_DIR.'index.php?mdl=sitemap',
			#
			'pay'			=> WEB_DIR.'index.php?mdl=news&mark=payment',
			'car'			=> WEB_DIR.'index.php?mdl=news&mark=delivery',
			'heart'			=> WEB_DIR.'index.php?mdl=news&mark=service',
			#
			'430'			=> WEB_DIR.'index.php?mdl=news&do=view&id=430',
			'431'			=> WEB_DIR.'index.php?mdl=news&do=view&id=431',
			'432'			=> WEB_DIR.'index.php?mdl=news&do=view&id=432',
			'433'			=> WEB_DIR.'index.php?mdl=news&do=view&id=433',
			'434'			=> WEB_DIR.'index.php?mdl=news&do=view&id=434',
			'435'			=> WEB_DIR.'index.php?mdl=news&do=view&id=435',
			'436'			=> WEB_DIR.'index.php?mdl=news&do=view&id=436',
			'437'			=> WEB_DIR.'index.php?mdl=news&do=view&id=437',
			'438'			=> WEB_DIR.'index.php?mdl=news&do=view&id=438',
			'439'			=> WEB_DIR.'index.php?mdl=news&do=view&id=439',
			'440'			=> WEB_DIR.'index.php?mdl=news&do=view&id=440',
			'441'			=> WEB_DIR.'index.php?mdl=news&do=view&id=441',
			'442'			=> WEB_DIR.'index.php?mdl=news&do=view&id=442',
			'443'			=> WEB_DIR.'index.php?mdl=news&do=view&id=443',
			#
			'aboutus'		=> WEB_DIR.'index.php?mdl=news&do=view&filename=about-us',
			'contactus'		=> WEB_DIR.'index.php?mdl=news&do=view&filename=contact-us',
			'jobs'			=> WEB_DIR.'index.php?mdl=news&do=view&filename=jobs',
			'joinin'		=> WEB_DIR.'index.php?mdl=news&do=view&filename=joinin',
			'law'			=> WEB_DIR.'index.php?mdl=news&do=view&filename=law',
			'ads'			=> WEB_DIR.'index.php?mdl=news&do=view&filename=ads',
			'links'			=> WEB_DIR.'index.php?mdl=news&do=view&filename=links',
		);
	}
	
	if(defined('DEBUG_PR') && DEBUG_PR == true){
		// ###
	}
//}

if(defined('DEBUG_FB') && DEBUG_FB == true){
	// ###
}

include_once APP_PTH.'_flush.php';
?>